#include "Disguise.h"

CDisguise::CDisguise(void)
{
}

CDisguise::~CDisguise(void)
{
}

void CDisguise::Init(int worldX, int worldY, CPlayer *playerPtr, Tiles *tilesPtr)
{
	pickedUp = false;
	x = worldX * 32;
	y = worldY * 32;
	
	height = 32;
	width = 32;
	tiles = tilesPtr;

	char picfile[] = "res/disguise.bmp";
	hImage = LoadImage(NULL, picfile, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);

	player = playerPtr;
}

void CDisguise::Draw(HDC graphics)
{
	if(!pickedUp)
	{
		RenderHelper::RenderBitmap(graphics, hImage, x,y, width, height);
	}
}

void CDisguise::Update()
{
	//if the apple is not picked up
	if(!pickedUp)
	{
		int DifX = (((int)player->x) - ((int)x));
		int DifY = (((int)player->y) - ((int)y));

		//if the player is at the same location=>dies
		if(DifX <= 30 && DifX >= -30 && DifY <= 30 && DifY >= -30)
		{
			if(!pickedUp)
			{
				CSoundPlayer::PlaySound1("music\\seed5.wav");
				player->waldoTime = player->waldoTime = 500;
				pickedUp = true;
			}
		}
	}
}